package com.tanhua.manage.controller;

import com.tanhua.manage.service.MovementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/manage/messages")
@Slf4j
public class MovementController {

    @Autowired
    private MovementService movementService;

    //动态分页
    @GetMapping
    public ResponseEntity<Object> showMessages(@RequestParam(defaultValue = "1")Integer page,
                                               @RequestParam(defaultValue = "10")Integer pagesize, @RequestParam(required = false) String uid, @RequestParam(required = false) String state) throws InvocationTargetException, IllegalAccessException {
        return movementService.findByPage(page,pagesize,uid,state);
    }

    //动态详情
    @GetMapping("/{id}")
    public ResponseEntity<Object> showPublish(@PathVariable("id") String id) throws InvocationTargetException, IllegalAccessException {
        return movementService.findById(id);
    }

    //动态审核通过【实战】
    @PostMapping("/pass")
    public ResponseEntity<Object> publishPass(@RequestBody List<String> payload){
        return movementService.publishPass(payload);
    }
}
